﻿#ifndef CLIENTCORRESPOND_H
#define CLIENTCORRESPOND_H

#include "../Command/Command.hpp"
#include <QObject>
#include <QTcpSocket>
#include <QHostAddress>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonValue>
#include <QDataStream>
#include "forward_config.h"
#include "forward_control.h"

class ClientCorrespond : public QObject
{
    Q_OBJECT
public:
    explicit ClientCorrespond(QObject *parent = nullptr);
    
signals:
    //连接状态信息更改
    void connectStateChange(CONNECT_STATUS);
    //转发状态信更改
    void forwardStatusChange(int,CONNECT_STATUS);
public slots:
    //连接到服务器
    void connectToServer();
    //断开服务器
    void stopServer();
    //打开一个新的端口
    void openPort(QJsonObject info);
    //关闭一个端口
    void closePort(QJsonObject info);
    //开始转发端口
    void recvResponse();
    //初始化
    void init();
private:
    QTcpSocket* socket = nullptr;
    Forward_Control *control = nullptr;
};

#endif // CLIENTCORRESPOND_H
